home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 10113 / 10113.xpi / content / overlay.js < prev   
Text File  |  2009-08-19  |  18KB  |  428 lines

  1. var igoogletabremover = {
  2.   onLoad: function() {
  3.       
  4.     // initialization code
  5.     this.initialized = true;
  6.     this.strings = document.getElementById("igoogletabremover-strings");
  7.  
  8. //Change verbage of enable disable based on preference
  9.       var prefManager = Components.classes["@mozilla.org/preferences-service;1"]
  10.                                 .getService(Components.interfaces.nsIPrefBranch);
  11.       var igtremover = document.getElementById("igoogletabremover-enable");
  12.       
  13.       if (prefManager.getBoolPref("extensions.igoogletabremover.boolEnable")){
  14.           igtremover.label="Disable iGoogle Tab Remover" ;
  15.       }
  16.       else {
  17.           igtremover.label="Enable iGoogle Tab Remover" ;
  18.       }
  19.  
  20.     var appcontent = document.getElementById("appcontent");   // browser
  21.     if(appcontent)
  22.       appcontent.addEventListener("DOMContentLoaded", igoogletabremover.onPageLoad, true);
  23.  
  24.   },
  25.  
  26.   onMenuItemCommand: function(e) {
  27.       var prefManager = Components.classes["@mozilla.org/preferences-service;1"]
  28.                                 .getService(Components.interfaces.nsIPrefBranch);
  29.       var igtremover = document.getElementById("igoogletabremover-enable");
  30.       
  31.       if (prefManager.getBoolPref("extensions.igoogletabremover.boolEnable")){
  32.           prefManager.setBoolPref("extensions.igoogletabremover.boolEnable",false);    
  33.           igtremover.label="Enable iGoogle Tab Remover"; 
  34.       }
  35.       else {
  36.           prefManager.setBoolPref("extensions.igoogletabremover.boolEnable",true);
  37.           igtremover.label="Disable iGoogle Tab Remover"; 
  38.       }
  39.   },
  40.     
  41.     onMenuItemCommand2: function(e) {
  42.             var newSS, styles='#doc3 td#col1, #footerwrap{ display: table-cell; }';
  43.             newSS=doc.createElement('link'); newSS.rel='stylesheet'; 
  44.             newSS.href='data:text/css,'+escape(styles); 
  45.             doc.getElementsByTagName("head")[0].appendChild(newSS); 
  46.   },
  47.  
  48.  
  49. onPageLoad: function(aEvent) {
  50.     var doc = aEvent.originalTarget; // doc is document that triggered "onload" event
  51.     if(doc.title.search("iGoogle") > -1){
  52.         if(doc.location.href.search("www.google.")>-1){
  53.             var prefManager = Components.classes["@mozilla.org/preferences-service;1"]
  54.                                     .getService(Components.interfaces.nsIPrefBranch);
  55.             if (prefManager.getBoolPref("extensions.igoogletabremover.boolEnable")==true){
  56.                 var sFullModeHeight = doc.getElementById("nhdrwrapsizer").offsetHeight + 'px';
  57.                 //alert(sFullModeHeight);
  58.                 var mydiv = doc.createElement('div');
  59.                 mydiv.id='igoogletabremoverdivStayTopLeft';
  60.                 mydiv.style.position='absolute';
  61.                 mydiv.style.display='none';
  62.                 mydiv.style.zIndex=1999;
  63.                 mydiv.className='leftunselectedtab';
  64.                 mydiv.style.borderStyle='outset';
  65.                 
  66.                 mydiv.addEventListener('click',function (e) {
  67.                     var el = doc.getElementById('igoogletabremoverdivStayTopLeft');
  68.                     el.style.display='none';
  69.                     },false);
  70.                 
  71.                 
  72.                 var tbl = doc.createElement("table");
  73.                 
  74.                 var row = doc.createElement("tr");
  75.                 row.id='igoogleremoverRW';
  76.                 var tabcell = doc.getElementById('col1');
  77.                 var cell = tabcell.cloneNode(true);
  78.                 tabcell.id='igoogleremoverMenucol1';
  79.                 cell.id='igoogleremoverMenu';
  80.                 row.appendChild(cell);
  81.                 tbl.appendChild(row);
  82.                 mydiv.appendChild(tbl);                                
  83.                 
  84.                                 
  85.                 var newSS, styles='#doc3 td#col1, #igooglefooteroriginal { display: none; }';
  86.                 newSS=doc.createElement('link'); newSS.rel='stylesheet'; 
  87.                 newSS.href='data:text/css,'+escape(styles); 
  88.                 doc.getElementsByTagName("head")[0].appendChild(newSS); 
  89.                                         
  90.                 var objElement=doc.getElementById("doc3");                    
  91.                 
  92.                 doc.getElementById('gsea').style.height='0px';                
  93.                 
  94.                 var myElement = doc.createElement('div');
  95.                 myElement.id='igoogleremoverBTN';
  96.                 myElement.style.width='100%';
  97.                 myElement.style.zIndex=1999;
  98.                 
  99.                 myElement.className='leftunselectedtab';
  100.                 var myElementTable= doc.createElement('table');
  101.                 myElementTable.width='100%';
  102.                 var myElementTableRow= doc.createElement('tr');
  103.                 var myElementTableCell1= doc.createElement('td');
  104.                 myElementTableCell1.innerHTML='    <a href="#" style="text-decoration:none">iGoogle Tabs</a>';
  105.                 myElementTableCell1.width='105px';
  106.                 myElementTableRow.appendChild(myElementTableCell1);
  107.                 
  108. /* Empty Cell */                
  109.                 var myElementTableCell3= doc.createElement('td');
  110.                 myElementTableCell3.innerHTML=' ';
  111.                 myElementTableRow.appendChild(myElementTableCell3);
  112.                 
  113.  
  114. //Timedyn Menu Added
  115.  
  116.     //Signing
  117.                 var mySig = doc.createElement('div');
  118.                 mySig.className='tab_view_title';
  119.                 mySig.id='igoogletabremoverSig';
  120.                 mySig.style.marginLeft='5pt';
  121.                 mySig.innerHTML='<hr/><a href="http://www.timedyn.com/igoogletabremover.htm" Title="This free addon provided to you by Timedyn.com" style="text-decoration:none;">Timedyn</a>';
  122.                 mydiv.appendChild(mySig);
  123.     
  124.                 var tblSearchToggle=doc.createElement('table');
  125.                 tblSearchToggle.style.display='none';
  126.                 tblSearchToggle.width='85%';
  127.                 tblSearchToggle.style.marginLeft='12pt';
  128.     //Row for Search Toggle
  129.                 var trSearchToggle=doc.createElement('tr');
  130.                 var tdSearchToggle1=doc.createElement('td');
  131.                 var tdSearchToggle2=doc.createElement('td');
  132.                 var inptSearchToggle=doc.createElement('input');
  133.                 inptSearchToggle.id='igoogleremoverMenuSearchToggle';
  134.                 inptSearchToggle.type='checkbox';
  135.                 inptSearchToggle.style.float='left';
  136.                 tdSearchToggle1.style.width='10px';
  137.                 tdSearchToggle1.appendChild(inptSearchToggle);
  138.                 
  139.                 var divSearchToggleText=doc.createElement('div');
  140.                 divSearchToggleText.innerHTML='Search Bar';
  141.                 divSearchToggleText.style.float='right';
  142.                 tdSearchToggle2.appendChild(divSearchToggleText);
  143.                 trSearchToggle.appendChild(tdSearchToggle1);
  144.                 trSearchToggle.appendChild(tdSearchToggle2);
  145.     
  146.     //Row for Header Resize
  147.                 var trSearchToggle2=doc.createElement('tr');
  148.                 //var tdSearchToggle1_2=doc.createElement('td');
  149.                 var tdSearchToggle2_2=doc.createElement('td');
  150.                 tdSearchToggle2_2.colSpan=2;
  151.                 tdSearchToggle2_2.style.borderTop="1px solid";
  152.                 var btnResizeHead=doc.createElement('div');
  153.                 btnResizeHead.id='igoogleremoverBTNResizeHead';
  154.                 btnResizeHead.innerHTML='<a href="#" style="text-decoration:none;text-align:center;">Resize Header</a>';
  155.                 tdSearchToggle2_2.appendChild(btnResizeHead);
  156.                 //trSearchToggle2.appendChild(tdSearchToggle1_2);
  157.                 trSearchToggle2.appendChild(tdSearchToggle2_2);
  158.                 tblSearchToggle.appendChild(trSearchToggle);
  159.                 tblSearchToggle.appendChild(trSearchToggle2);
  160.                 
  161.     //Row for Minimize Tabs
  162.                 var trSearchToggle3=doc.createElement('tr');
  163.                 var tdSearchToggle2_3=doc.createElement('td');
  164.                 tdSearchToggle2_3.colSpan=2;
  165.                 tdSearchToggle2_3.style.borderTop="1px solid";
  166.                 var btnMinimize=doc.createElement('div');
  167.                 btnMinimize.id='igoogleremoverBTNMinimize';
  168.                 btnMinimize.innerHTML='<a href="#" style="text-decoration:none;text-align:center;">Minimize Tabs</a>';
  169.                 tdSearchToggle2_3.appendChild(btnMinimize);
  170.                 //trSearchToggle3.appendChild(tdSearchToggle1_3);
  171.                 trSearchToggle3.appendChild(tdSearchToggle2_3);
  172.                 tblSearchToggle.appendChild(trSearchToggle3);        
  173.  
  174.                 mySig.appendChild(tblSearchToggle);
  175.  
  176.                 
  177.                 
  178.                 var myElementTableCell2= doc.createElement('td');
  179.                 myElementTableCell2.style.textAlign='right';
  180.                 myElementTableCell2.id="igoogletabremoverdivSearchCell"
  181.                 myElementTableCell2.innerHTML='<form action="http://www.google.com/cse" id="cse-search-box"><input type="hidden" name="cx" value="partner-pub-1486060006013891:uuafljtdej4" /><input type="hidden" name="ie" value="ISO-8859-1" /><input type="text" id="q" name="q" size="15" /><input type="submit" id="sa" name="sa" value="Search"/></form><script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script>';
  182.                 myElementTableRow.appendChild(myElementTableCell2);
  183.  
  184.                 
  185.                 //Search Toggle
  186.                 var myElementTableCell4= doc.createElement('td');
  187.                 myElementTableCell4.width='10px';
  188.                 var searchToggleDiv=doc.createElement("div");
  189.                 searchToggleDiv.id='igoogletabremoversearchToggleDiv';
  190.                 searchToggleDiv.innerHTML='<a href="#" style="text-decoration:none" Title="Click to toggle search On/Off."><<</a>';
  191.                 searchToggleDiv.className='leftunselectedtab';
  192.                 myElementTableCell4.appendChild(searchToggleDiv);
  193.                 myElementTableRow.appendChild(myElementTableCell4);
  194.                 
  195.                 myElementTable.appendChild(myElementTableRow);
  196.                 myElement.appendChild(myElementTable);
  197.                 if (prefManager.getIntPref('extensions.igoogletabremover.intHeadHeight')>0){
  198.                 if (prefManager.getBoolPref("extensions.igoogletabremover.boolSearchToggle")==true){    
  199.                     myElementTableCell2.style.display='';
  200.                     inptSearchToggle.checked=true;
  201.                     }
  202.                     else {
  203.                     myElementTableCell2.style.display='none';
  204.                     inptSearchToggle.checked=false;
  205.                     }
  206.                 }
  207.             
  208.                 
  209.             
  210.             objElement.insertBefore(myElement, objElement.firstChild);
  211.             myElementTableCell1.appendChild(mydiv);
  212.             
  213.             //Toggle Header Height
  214.             var btnShowHead=doc.getElementById("igoogleremoverBTNShowHead");
  215.             
  216.             
  217.             var intHeaderHeight = prefManager.getIntPref('extensions.igoogletabremover.intHeadHeight')
  218.  
  219.             if (intHeaderHeight == 460){
  220.                 doc.getElementById("nhdrwrapsizer").style.minHeight= sFullModeHeight;
  221.                 doc.getElementById("nhdrwrapsizer").style.height= sFullModeHeight;
  222.             }else
  223.             {
  224.                 doc.getElementById("nhdrwrapsizer").style.minHeight= intHeaderHeight + 'px';
  225.                 doc.getElementById("nhdrwrapsizer").style.height= intHeaderHeight + 'px';
  226.                 if (intHeaderHeight<doc.getElementById('addstuff').offsetTop+doc.getElementById('addstuff').offsetHeight){
  227.                     doc.getElementById('addstuff').style.display='none';
  228.                 }
  229.                 if (intHeaderHeight<doc.getElementById('btnG').offsetTop +doc.getElementById('btnG').offsetHeight){
  230.                     doc.getElementById('gsea').style.display='none';
  231.                     doc.getElementById("igoogletabremoverdivSearchCell").style.display='';
  232.                     inptSearchToggle.checked=true;
  233.                 }
  234.             }
  235.             
  236.             
  237.             /*  Reenable Footer */
  238.             var objFoot=doc.getElementById("footerwrap");                    
  239.                 var copyFoot = objFoot.cloneNode(true);
  240.                 objFoot.id='igooglefooteroriginal';
  241.                 copyFoot.style.display='';
  242.             doc.body.appendChild(copyFoot);
  243.  
  244.             /* Check for tabStrip Minimize */
  245.             if (prefManager.getBoolPref('extensions.igoogletabremover.boolTabStrip')==false){
  246.                 myElement.style.display='none';
  247.                 var objGbar=doc.getElementById('gbar');
  248.                 var myMax = doc.createElement('div');
  249.                 myMax.style.cssFloat='right';
  250.                 myMax.innerHTML='<a href="#" style="text-decoration:none;" title="Restore iGoogle Tab Remover"><small> ▼</small></a>';
  251.                 objGbar.appendChild(myMax);
  252.                 myMax.addEventListener('click',function (e) {
  253.                     myElement.style.display='';
  254.                     objGbar.removeChild(myMax);
  255.                     prefManager.setBoolPref('extensions.igoogletabremover.boolTabStrip',true);
  256.                 },false);
  257.             }
  258.             
  259.             
  260.             
  261.             
  262.             var dcid=tabcell.firstChild;
  263.             tabcell.removeChild(dcid);
  264.                         
  265.             searchToggleDiv.addEventListener('click',function (e) {
  266.                 var el = doc.getElementById('igoogletabremoverdivSearchCell');
  267.                 if (el.style.display=='none'){
  268.                     el.style.display='';
  269.                     prefManager.setBoolPref('extensions.igoogletabremover.boolSearchToggle',true);
  270.                     inptSearchToggle.checked=true;
  271.                 }
  272.                 else {el.style.display='none';
  273.                     prefManager.setBoolPref('extensions.igoogletabremover.boolSearchToggle',false);
  274.                     inptSearchToggle.checked=false;
  275.                 }
  276.                 },false);
  277.             
  278.                 
  279.             inptSearchToggle.addEventListener('click',function (e) {
  280.                 var el = doc.getElementById('igoogletabremoverdivSearchCell');
  281.                 if (inptSearchToggle.checked==true){
  282.                     el.style.display='';
  283.                     prefManager.setBoolPref('extensions.igoogletabremover.boolSearchToggle',true);
  284.                 }
  285.                 else {el.style.display='none';
  286.                     prefManager.setBoolPref('extensions.igoogletabremover.boolSearchToggle',false);
  287.                 }
  288.                 },false);
  289.                 
  290.             myElementTableCell1.addEventListener('mouseover',function (e) {
  291.                 var el = doc.getElementById('igoogletabremoverdivStayTopLeft');
  292.                 el.style.display='';
  293.                 },false);
  294.             myElementTableCell1.addEventListener('mouseout',function (e) {
  295.                 var el = doc.getElementById('igoogletabremoverdivStayTopLeft');
  296.                 el.style.display='none';
  297.                 },false);
  298.             mySig.addEventListener('mouseover',function (e) {
  299.                 tblSearchToggle.style.display='';
  300.                 },false);
  301.             mySig.addEventListener('mouseout',function (e) {
  302.                 tblSearchToggle.style.display='none';
  303.                 },false);            
  304.             btnMinimize.addEventListener('click',function (e) {
  305.                 myElement.style.display='none';
  306.                 prefManager.setBoolPref('extensions.igoogletabremover.boolTabStrip',false);
  307.                 var objGbar=doc.getElementById('gbar');
  308.                 var myMax = doc.createElement('div');
  309.                 myMax.style.cssFloat='right';
  310.                 myMax.innerHTML='<a href="#" style="text-decoration:none;" title="Restore iGoogle Tab Remover"><small> ▼</small></a>';
  311.                 objGbar.appendChild(myMax);
  312.                 myMax.addEventListener('click',function (e) {
  313.                     myElement.style.display='';
  314.                     objGbar.removeChild(myMax);
  315.                     prefManager.setBoolPref('extensions.igoogletabremover.boolTabStrip',true);
  316.                 },false);
  317.             },false);
  318.                 
  319.             btnResizeHead.addEventListener('click',function (e) {
  320.                 var tmpVar=doc.getElementById("nhdrwrapsizer");
  321.                 tmpVar.style.minHeight= sFullModeHeight;
  322.                 tmpVar.style.height= sFullModeHeight;
  323.                 var coverDiv = doc.createElement('div');
  324.                 coverDiv.style.position='absolute';
  325.                 coverDiv.style.height='800px';
  326.                 coverDiv.style.top='0';
  327.                 coverDiv.style.left='0';
  328.                 coverDiv.style.width='100%';
  329.                 //coverDiv.style.zIndex='2000';
  330.                 //coverDiv.innerHTML="abc";
  331.                 doc.body.appendChild(coverDiv);
  332.                 var positionDiv = doc.createElement('div');
  333.                 positionDiv.style.zIndex='3000';
  334.                 positionDiv.style.position='absolute';
  335.                 positionDiv.style.top= tmpVar.offsetTop;
  336.                 positionDiv.style.left='0';
  337.                 positionDiv.style.width='100%';
  338.                 positionDiv.style.backgroundColor='grey';
  339.                 positionDiv.style.opacity='0.75';
  340.                 var positionDivBTN = doc.createElement('div');
  341.                 positionDivBTN.style.zIndex='3001';
  342.                 positionDivBTN.style.position='absolute';
  343.                 positionDivBTN.style.top=tmpVar.offsetTop;
  344.                 positionDivBTN.style.left='0';
  345.                 positionDivBTN.style.height='100%';
  346.                 positionDivBTN.style.textAlign='center';
  347.                 positionDivBTN.style.opacity='1';
  348.                 var positionDivBTNOK = doc.createElement('div');
  349.                 positionDivBTNOK.innerHTML='<input type="button" value="Finished"/>';
  350.                 positionDivBTNOK.style.position='absolute';
  351.                 positionDivBTNOK.style.float='left';
  352.                 positionDivBTNOK.style.width='150px';
  353.                 positionDivBTNOK.style.top= '-20px';
  354.                 
  355.                 var positionDivBTNReset = doc.createElement('div');
  356.                 positionDivBTNReset.style.zIndex='3001';
  357.                 positionDivBTNReset.innerHTML='<input type="button" value="Reset"/>';
  358.                 positionDivBTNReset.style.position='absolute';
  359.                 positionDivBTNReset.style.float='right';
  360.                 positionDivBTNReset.style.top=tmpVar.offsetTop;
  361.                 positionDivBTNReset.style.left='140px';
  362.                 positionDivBTNReset.style.top= '-20px';
  363.                 
  364.                 var positionDivTxt = doc.createElement('div');
  365.                 positionDivTxt.innerHTML='Click the header to resize.';
  366.                 positionDivTxt.style.position='absolute';
  367.                 positionDivTxt.style.float='right';
  368.                 positionDivTxt.style.top='-20px';
  369.                 positionDivTxt.style.left='210px';
  370.                 positionDivTxt.style.backgroundColor='white';
  371.                 positionDivTxt.style.color='red';
  372.                 positionDivTxt.style.fontSize='18pt';
  373.                 positionDivTxt.width='400px';
  374.                 positionDivTxt.style.whiteSpace='nowrap';
  375.                 
  376.                 myElement.appendChild(positionDiv);
  377.                 myElement.appendChild(positionDivBTN);
  378.                 positionDivBTN.appendChild(positionDivBTNOK);
  379.                 positionDivBTN.appendChild(positionDivBTNReset);
  380.                 positionDivBTN.appendChild(positionDivTxt);
  381.                 doc.getElementById('addstuff').style.display='';
  382.                 doc.getElementById('gsea').style.display='';
  383.                 tmpVar.style.minHeight=sFullModeHeight;
  384.                 tmpVar.style.height= sFullModeHeight;
  385.                 positionDiv.style.height=doc.getElementById('nhdrwrap').offsetHeight + 'px';
  386.                 prefManager.setIntPref('extensions.igoogletabremover.intHeadHeight',460);
  387.                 
  388.                 positionDiv.addEventListener('click',function (e) {
  389.                     var intH = e.clientY - tmpVar.offsetTop;
  390.                     if (intH<doc.getElementById('addstuff').offsetTop){
  391.                         doc.getElementById('addstuff').style.display='none';
  392.                     }
  393.                     if (intH<doc.getElementById('btnG').offsetTop +doc.getElementById('btnG').offsetHeight){
  394.                         doc.getElementById('gsea').style.display='none';
  395.                         doc.getElementById("igoogletabremoverdivSearchCell").style.display='';
  396.                         inptSearchToggle.checked=true;
  397.                     }
  398.                     
  399.                     
  400.                     positionDiv.style.height=intH +'px';
  401.                     tmpVar.style.minHeight=intH +'px';
  402.                     tmpVar.style.height=intH +'px';
  403.                 prefManager.setIntPref('extensions.igoogletabremover.intHeadHeight',intH);    
  404.                 },false);
  405.                 positionDivBTNOK.addEventListener('click',function (e) {
  406.                     positionDiv.style.display='none';
  407.                     positionDivBTN.style.display='none';
  408.                     coverDiv.style.display='none';
  409.                     doc.body.removeChild(coverDiv);
  410.                     },false);
  411.                 positionDivBTNReset.addEventListener('click',function (e) {
  412.                     doc.getElementById('addstuff').style.display='';
  413.                     doc.getElementById('gsea').style.display='';
  414.                     tmpVar.style.minHeight=sFullModeHeight;
  415.                     tmpVar.style.height= sFullModeHeight;
  416.                     positionDiv.style.height=doc.getElementById('nhdrwrap').offsetHeight + 'px';
  417.                     prefManager.setIntPref('extensions.igoogletabremover.intHeadHeight',460);
  418.                     },false);
  419.                 },false);        
  420.             }
  421.         }
  422.     }
  423. }
  424. };
  425. window.addEventListener("load", function(e) { igoogletabremover.onLoad(e); }, false);
  426.  
  427.  
  428.